<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no" />
		<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<title>PDF</title>
		<link rel="stylesheet" href="html/pdf/style.css" />
		<link rel="stylesheet" href="html/pdf/pdfh5.css" />
		<style>
			html,body {
	            width: 100%;
	            height: 100%;
	        }
    </style>
	</head>

	<body>
		<div id="pdf-view" style="width:100%,height:100%">
			<p>备注:当前显示为压缩后的图片</p>
		</div>
		<script src="./pdf/pdf.js" type="text/javascript" charset="utf-8"></script>
		<script src="./pdf/pdf.worker.js" type="text/javascript" charset="utf-8"></script>
		<script src="./pdf/jquery-2.1.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="./pdf/pdfh5.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var pdfh5;
			$(function() {
				$("#pdf-view").show()
				var url = getQuery('url');
				pdfh5 = new Pdfh5('#pdf-view', {
					pdfurl: url,
					// background:{
					// 	image:"url('pdfh5.png')",
					// 	repeat:"no-repeat",
					// 	position:"left top",
					// 	size:"40px 40px"
					// },
					scale:0.6,
					zoomEnable:false,
					URIenable:true //开启浏览器地址栏file参数获取
				});

				//pdf准备开始渲染，此时可以拿到pdf总页数
				pdfh5.on("ready", function() {
					console.log("pdf准备开始渲染，总页数：" + this.totalNum)
				})
				//监听pdf渲染成功
				pdfh5.on("success", function(time) {
					time = time / 1000
					console.log("pdf渲染完成，总耗时" + time + "秒");
				})
			})
			function getQuery(name) {
				// 正则：[找寻'&' + 'url参数名字' = '值' + '&']（'&'可以不存在）
				let reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
				let r = window.location.search.substr(1).match(reg);
				if(r != null) {
					// 对参数值进行解码
					return decodeURIComponent(r[2]);
				}
				return null;
			}
		</script>
	</body>

</html>
